import React, {Component} from "react";
import { AppState } from 'react-native'
import {StackNavigator} from "react-navigation";
import { Modal } from 'antd-mobile'
import './libs/storage'
import {Menu} from "./scenes/menu/Menu";
import { ProducerMenu } from './scenes/menu/ProducerMenu'
import { WorkShopMenu } from './scenes/menu/WorkShopMenu'
import Login from "./scenes/login/Login";
import { SignStack } from "./scenes/login/SignStack"
import {OutBoundStack} from "./scenes/outbound/OutBoundStack";
import {EntryStack} from "./scenes/entry/EntryStack";
import {ReturnedStack} from "./scenes/returned/ReturnedStack";
import MaterialsSearch from "./scenes/home/MaterialsSearch";
import codePush from 'react-native-code-push'

const RootStack = StackNavigator({
  Login: { screen: Login },
  SignStack: { screen: SignStack},
  Menu: { screen: Menu }, //代理商
  ProducerMenu: { screen: ProducerMenu },
  WorkShopMenu: {screen: WorkShopMenu},
  MaterialsSearch: { screen: MaterialsSearch },
  EntryStack: { screen: EntryStack },
  OutBoundStack: { screen: OutBoundStack },
  ReturnedStack: { screen: ReturnedStack }
}, {
  headerMode: 'none'
})

export default class extends Component {
  constructor(props) {
    super(props)
  }

  componentDidMount() {
    AppState.addEventListener("change", (newState) => {
      console.log('state change....')
      newState === "active" && codePush.sync({
        updateDialog: {
          appendReleaseDescription: true,
          descriptionPrefix:'\n\n更新内容：\n',
          title:'更新',
          mandatoryUpdateMessage:'',
          mandatoryContinueButtonLabel:'更新',
        },
        installMode: codePush.InstallMode.IMMEDIATE,
        deploymentKey: "Rd1zOkJ1sDJWtyVjXbvD4y-bmrW32fe1f6e0-4f79-4648-8e55-87c43b4b90de",
      });
    });
  }


  render() {
    return <RootStack onNavigationStateChange={null}/>
  }
}
